import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { OpenExcelButton, ModDataButton, DelDataButton } from '../Common/options'
import { v4 } from 'uuid'

export const LabMonthReport = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    url: 'getLabMonthReportExcel',
                    pos: 'posLabMonthReportExcel',
                    labMonthReportUuid: v4(),
                }}
            />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'LabMonthReport' },
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, hideInModify: true },
            {
                dataIndex: 'eventDate',
                title: '巡检日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
            },
            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 160,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenExcelButton
                            key="two"
                            title="查看明细"
                            OptionsEvent={OptionsEvent}
                            data={{
                                save: true,
                                submit: true,
                                url: 'getLabMonthReportExcel',
                                pos: 'posLabMonthReportExcel',
                                labMonthReportUuid: uuid,
                            }}
                        />,
                        <DelDataButton OptionsEvent={OptionsEvent} key="del" title="删除" url={url} uuid={uuid} />,
                    ]
                },
            },
        ],
    }

    return data
}
